import { AnswerItem, RequestGeneticPaper, RequestPaper } from "../index";
import axios from "axios";
import { API_NAME } from "./contants.ts";

const preparePaperAPI = (paper: RequestPaper) => {
  return axios.post(`${API_NAME}/paper/prepare`, {
    ...paper,
  });
};

const preparePaperByGeneticAPI = (paper: RequestGeneticPaper) => {
  return axios.post(`${API_NAME}/paper/getPaper`, {
    ...paper,
  });
};

const submitPaperAPI = (answers: AnswerItem[]) => {
  return axios.post(`${API_NAME}/paper/submit`, answers);
};

const getAllHistoryPaperAPI = (id: number) => {
  return axios.get(`${API_NAME}/paper/user/${id}`);
};

const getHistoryPaperByIDAPI = (id: number) => {
  return axios.get(`${API_NAME}/paper/info/${id}`);
};

const getAlgorithmHistoryByPaperIDAPI = (id: number) => {
  return axios.get(`${API_NAME}/paper/algo/info/${id}`);
};

const getAlgorithmHistoryTableDataByPaperIDAPI = (id: number) => {
  return axios.get(`${API_NAME}/paper/algo/table/${id}`);
};

export {
  preparePaperAPI,
  preparePaperByGeneticAPI,
  submitPaperAPI,
  getAllHistoryPaperAPI,
  getHistoryPaperByIDAPI,
  getAlgorithmHistoryByPaperIDAPI,
  getAlgorithmHistoryTableDataByPaperIDAPI
};
